package com.aabte.feignhttp.springmvcdemo.common.feign;

import com.aabte.feignhttp.springmvcdemo.common.common.ResponseBean;
import com.aabte.feignhttp.springmvcdemo.common.common.User;
import com.aabte.feignhttp.springmvcfeignhttpclient.annotation.SpringMvcFeignHttpApi;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;

@SpringMvcFeignHttpApi(
        url = "${hello_url}",
        path = "${hello_path}"
)
@Component
public interface FeignService {

    @RequestMapping(value = "/hello",
            consumes = {"application/json"},
            produces = {"application/json"})
    ResponseBean hello();

    @RequestMapping(value = "/user",
            consumes = {"application/json"},
            produces = {"application/json"})
    ResponseBean user();

    @RequestMapping(value = "/user/{name}",
            consumes = {"application/json"},
            produces = {"application/json"})
    ResponseBean userByName1(@PathVariable("name") String name);

    @RequestMapping(value = "/user/url",
            consumes = {"application/json"},
            produces = {"application/json"})
    ResponseBean userByName2(@RequestParam("name") String name);

    @RequestMapping(value = "/user",
            method = RequestMethod.POST,
            consumes = {"application/json"},
            produces = {"application/json"})
    ResponseBean addUser(@RequestBody User user);

    @RequestMapping(value = "/user",
            method = RequestMethod.PUT,
            consumes = {"application/json"},
            produces = {"application/json"})
    ResponseBean updateUser(@RequestBody User user);

    @RequestMapping(value = "/user",
            method = RequestMethod.DELETE,
            consumes = {"application/json"},
            produces = {"application/json"})
    ResponseBean deleteUser(@PathVariable("id") Integer id);


}
